﻿using MediatR;
using T.Settlement.Domain;
using T.Settlement.Read.API.Application.Command.ExpensesCommand;
using T.Settlement.Repository.SettlementInterface;

namespace T.Settlement.Read.API.Application.CommandHandlers.ExpensesHandler
{
    public class ExpensesBackfillCommandHandler : IRequestHandler<ExpensesBackfillCommand, Expenses>
    {
        private readonly IExpensesSRepository _expensesSRepository;
        public ExpensesBackfillCommandHandler(IExpensesSRepository expensesSRepository)
        {
            _expensesSRepository = expensesSRepository;
        }
        /// <summary>
        /// 返填
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<Expenses> Handle(ExpensesBackfillCommand request, CancellationToken cancellationToken)
        {
            var list = (await _expensesSRepository.GetAllAsync()).Where(x => x.ExpensesId == request.ExpensesId).FirstOrDefault();
            return list;
        }
    }
}
